package run.aaa.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import run.aaa.entity.User;
import run.aaa.service.IUserService;

@Controller
@RequestMapping(value = "/User")
public class UserController {
	private static final Logger logger = Logger.getLogger(UserController.class);
	
	@Autowired
	private IUserService userService;

	@RequestMapping(value = "/say/{msg}", produces = "application/json;charset=UTF-8")
	@ResponseBody
	public String say(@PathVariable(value = "msg") String msg) {
		logger.info("say=" + msg);  
		return "{msg:you say:" + msg+"}";
	}

	@RequestMapping(value = "/person/{id:\\d+}", method = RequestMethod.GET)
	public @ResponseBody User getPerson(@PathVariable("id") int id) {
		logger.info("获取用户id=" + id);  
		return userService.getUserById(id);
	}

}
